from typing import TYPE_CHECKING
import json
if TYPE_CHECKING:
    from .Move import MoveBase
    from .Skill import SkillBase
    from .Pos import Pos, PosSet
    from .Death import DeathBase
    from .Board import Board


class ChessBase:
    death: "DeathBase" = None
    pos: "Pos" = None
    board: "Board" = None
    skill: "SkillBase" = None
    move: "MoveBase" = None
    type: str = "UndefinedChess"
    cost: int = 0
    point: int = 0
    player: int = 0

    def __repr__(self):
        return f"<{self.type} of player {self.player}>"

    def to_json(self):
        nar = self.pos.toNARTuple()  # TODO 若为 transferer 则还有 id 参数
        return json.dumps({'pos': {'x': nar[0], 'y': nar[1], 'z': nar[2]}, 'owner': self.player, 'type': self.type})

    def __init__(self):
        pass

    def __init__(self, type: str, pos: "Pos", player: int, death: "DeathBase", skill: "SkillBase", move: "MoveBase", cost: int, point: int, board: "Board" = None):
        self.pos = pos
        self.player = player
        self.type = type
        self.death = death
        self.skill = skill
        self.move = move
        self.cost = cost
        self.point = point
        self.board = board
